package com.whh.starter.autoConfig;

import com.whh.starter.web.SystemFilter;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

@Configuration
@ComponentScan(value = {"com.whh.starter.web"})
public class WebAutoConfig {
    @Bean
    @Order(Integer.MIN_VALUE)
    @Qualifier("systemFilter")
    public FilterRegistrationBean<SystemFilter> systemFilter() {
        FilterRegistrationBean<SystemFilter> registration = new FilterRegistrationBean<>();
        // 注入Filter
        registration.setFilter(new SystemFilter());
        // 拦截规则
        registration.addUrlPatterns("/*");
        return registration;
    }
}
